package net.flydy.ywxcx.wxcloudrun.config;

import lombok.Data;

import java.io.Serializable;

@Data
public class CacheEntity<T> implements Serializable {

    /**
     * 过期时间，单位秒
     */
    private int ttl = -1;

    private     T data = null;
    public CacheEntity(T d) {
        this.data = d;
    }

    public CacheEntity(T d, int ttl) {
        this.ttl = ttl;
        this.data = d;
    }
    public T getData(Class<T> clazz) {
        if (data != null && data.getClass() == clazz) {
            return data;
        }else {
            return null;
        }
    }

}
